using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using SumGam;
using SumGam.Globals;
using SumGam.Structs;
using SumGam.Classes;
namespace SumGam
{
    public static class Helpers
    {
        public static KeyComparison GetKeyState(Keys key)
        {
            KeyboardState NewState = Misc.NewKeyboardState;
            KeyboardState OldState = Misc.OldKeyboardState;
            KeyComparison ret = new KeyComparison();
            if (NewState.IsKeyDown(key))
            {
                //Console.WriteLine("hey the key is down");
                ret.IsDown = true;
                if (OldState.IsKeyDown(key))
                {
                    ret.IsHeld = true;
                }
                else
                {
                    ret.JustPressed = true;
                }
            }
            else
            {
                //Console.WriteLine("hey the key is up");
                ret.IsUp = true;
                if (OldState.IsKeyDown(key))
                {
                    ret.JustReleased = true;
                }
            }
            return ret;
        }
        public static void SetMajorState(BaseState NewState) //I know this timing of setting Justchanged to true is going to bite me in the ass later, but right now i dont care
        {
            BaseState OldState = States.MajorState;
            OldState.OnExit(NewState);
            NewState.JustChanged = true;
            States.MajorState = NewState;
            States.MajorState.OnEnter(OldState);
        }
        public static void SetMinorState(BaseState NewState)
        {
            BaseState OldState = States.MinorState;
            NewState.JustChanged = true;
            OldState.OnExit(NewState);
            States.MinorState = NewState;
            States.MinorState.OnEnter(OldState);
        }
    }
}